import request from '@/utils/request'

//获取列表
export const indexApi = async (params) => {
    return await request.get({ 
        url: '/api/roles/index',
        params
    })
}

//新增行
export const addApi = async (data) => {
    return await request.post({ 
        url: '/api/roles/add',
        data
    })
}


//编辑行
export const editApi = async (data) => {
    return await request.post({ 
        url: '/api/roles/edit',
        data
    })
}

//删除行
export const delApi = async (data) => {
    return await request.post({ 
        url: '/api/roles/del',
        data
    })
}

//更新字段
export const updateFieldApi = async (data) => {
    return await request.post({ 
        url: '/api/roles/edit?update=field',
        data
    })
}

//获取节点权限列表（当前和父级）
export const getNodePermissionsApi = async (params) => {
    return await request.get({ 
        url: '/api/roles/nodePermissions',
        params
    })
}


//编辑权限
export const editPermissionsApi = async (data) => {
    return await request.post({ 
        url: '/api/roles/editPermissions',
        data
    })
}

// 获取已关联用户信息
export const getRelatedUsersApi = async (params) => {
    return await request.get({ 
        url: '/api/roles/getRelatedUsers',
        params
    })
}

// 批量设置已关联用户
export const setRelatedUsersApi = async (data) => {
    return await request.post({ 
        url: '/api/roles/setRelatedUsers',
        data
    })
}